package com.tasks.task01;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

public class NumberSortReducer extends Reducer<IntWritable,NullWritable,IntWritable,IntWritable> {
  private int rank = 0;
  private IntWritable intWriable = new IntWritable();

  @Override
  protected void reduce(IntWritable key,Iterable<NullWritable> values,Context context) throws IOException, InterruptedException {
    for(NullWritable ignored : values){
      rank += 1;
      intWriable.set(rank);
      context.write(intWriable, key);
    }
  }
}
